import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from "@/router"
import i18n from "@/lang"
import {createPinia} from "pinia"
import piniaPersist from "pinia-plugin-persist"
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App)
const pinia = createPinia()
//创建pinia过后，我们需要给pinia设置插件。在去进行app.use(pinia)
pinia.use(piniaPersist)
//定义全局指令 onblur  onfocus
//vue自定义指令都必须 v-xxx开始设计
app.directive("focus", (el, binding) => {
    //直接让当前这个元素获取焦点
    el.focus()
})
app.directive("bgColor",(el,binding)=>{
    console.log(binding);
    el.style.backgroundColor = binding.value
})

//app实例上面挂载插件，以后每个组件都可以使用router这个插件
app.use(router)
app.use(i18n)
app.use(pinia)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.mount('#app')

